 <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:decorate template="/tema/padrao.xhtml">
        <ui:define name="centro">
            <h:form> 
                <h1 class="title ui-widget-header ui-corner-all">Cadastrar imóvel</h1>

                <p:fieldset legend="Dados do imóvel">  
                    <div align="left">
                        <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
                            <h:outputText value="Options: " /> 
                            <p:selectOneRadio  id="opcao" value="#{imovelBean.imovel.opcao}" >  
                                <f:selectItem itemLabel="Alugar" itemValue="Alugar" />  
                                <f:selectItem itemLabel="Vender" itemValue="Vender" />  
                                <f:selectItem itemLabel="Alugar/Vender" itemValue="Alugar/Vender" />  
                            </p:selectOneRadio>

                            <h:outputText value="Tipo: " />  
                            <p:selectOneRadio id="tipo" value="#{imovelBean.imovel.tipo}">                         
                                <f:selectItem itemLabel="Casa" itemValue="casa" />  
                                <f:selectItem itemLabel="Apartamento" itemValue="apartamento" /> 
                                <f:selectItem itemLabel="Comercial" itemValue="comercial"/> 
                            </p:selectOneRadio> 
                        </h:panelGrid> 

                        <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">

                            <h:outputText value= "Código do Proprietario:"/>
                            <p:inputText converter="proprietarioConverter" id="codigo" value="#{imovelBean.imovel.dono}"/>
                            <h:outputText value= "Área útil:"/>
                            <p:inputText id="areaUtil" value="#{imovelBean.imovel.areaUtil}"/>
                            <h:outputText value="Área total:" />
                            <p:inputText id="areaTotal" value="#{imovelBean.imovel.areaTotal}"/>
                            <h:outputText value="Nº de quartos:" />
                            <p:inputText id="quartos" value="#{imovelBean.imovel.numQuartos}"/>
                            <h:outputText value="Nº de suítes:" />
                            <p:inputText id="suites" value="#{imovelBean.imovel.numSuites}"/>
                            <h:outputText value="Nº de garagens:" />
                            <p:inputText id="garagens" value="#{imovelBean.imovel.numGaragens}"/>
                            <h:outputText value="Valor: " />
                            <p:inputText id="valor" value="#{imovelBean.imovel.valor}"/>
                            <h:outputText value="Cidade: " />
                            <p:inputText id="cidade" value="#{imovelBean.imovel.cidade}"/>
                            <h:outputText value="Estado:"/>
                            <p:inputText id="estado" value="#{imovelBean.imovel.estado}"/>                    
                            <h:outputText value="Endereço:" />
                            <p:inputText id="endereco" value="#{imovelBean.imovel.endereco}"/>
                            <h:outputText value="Bairro: " />
                            <p:inputText id="bairro" value="#{imovelBean.imovel.bairro}"/>
                            <h:outputText value="Obs: " />
                            <h:inputTextarea id="obs" rows="6" cols="65" value="#{imovelBean.imovel.obs}"/>
                           
                            <h:outputText value="Foto (Selecione apenas uma foto!)"/>
                            <h:form enctype="multipart/form-data"> 
                                <!--<p:graphicImage value="#{imovelBean.imagem}" cache="false" id="imagem" /> update="imagem" so funciona com @SessionScoped ou Servlet--> 
                                <p:fileUpload  fileUploadListener="#{imovelBean.handleFileUpload}"  
                                    mode="advanced"  
                                    update="messages"  
                                    auto="false"  
                                    multiple="false"
                                    sizeLimit="100000"   
                                    allowTypes="/(\.|\/)(gif|jpeg|png)$/"/> 
                                <p:growl id="messages" showDetail="true"/> 
                            </h:form> 
                            
                            <br></br><br></br>
                            <f:facet name="footer">  
                                <p:commandButton type="submit" action="#{imovelBean.inserir}" value="Enviar" icon="ui-icon-check" style="margin:0"/>

                                <p:commandButton type="reset" value="Limpar" icon="ui-icon-check" style="margin:0"/>  
                            </f:facet>  
                        </h:panelGrid> 
                    </div>
                </p:fieldset>
            </h:form>
        </ui:define>
    </ui:decorate>
</html>

